import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:ty_smart_watch/common/images_url.dart';
import 'package:ty_smart_watch/page/health/controller/common_controller.dart';

class SleepWeakupComponent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceAround,
      children: [
        Item(type: 1),
        Item(type: 2),
      ],
    );
  }
}

class Item extends StatelessWidget {
  final int type;

  Item({super.key, required this.type});

  final CommonController controller = Get.find();

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Obx(
          () => Visibility(
              visible: controller.dateTypeIndex.value != 0,
              child: Text("本周平均${getTitle(type)}时间", style: TextStyle(fontSize: 10))),
        ),
        Row(
          children: [
            Image.asset(getIcon(type), width: 16, height: 16),
            Text(
              "22:22",
              style: TextStyle(fontSize: 12, color: Color(0xFFB4B4BD)),
            ),
            Text(
              "(早睡23min)",
              style: TextStyle(fontSize: 12, color: Color(0xFFB4B4BD)),
            ),
          ],
        )
      ],
    );
  }

  String getTitle(int type) {
    String text = "";
    if (type == 1) {
      text = "睡觉";
    }
    if (type == 2) {
      text = "起床";
    }
    return text;
  }

  String getIcon(int type) {
    String src = "";
    if (type == 1) {
      src = SLEEP_MOON;
    }
    if (type == 2) {
      src = SLEEP_SUN;
    }
    return src;
  }
}
